In [1]:
require(extrafont)
require(tidyverse)
library(ggpubr)
library(gridExtra)
library(cowplot)
cbPalette <- c( "#000000","#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7")
Loading required package: extrafont
Registering fonts with R
Loading required package: tidyverse
── Attaching packages ─────────────────────────────────────── tidyverse 1.2.1 ──
✔ ggplot2 3.1.1       ✔ purrr   0.3.2  
✔ tibble  2.1.1       ✔ dplyr   0.8.0.1
✔ tidyr   0.8.3       ✔ stringr 1.4.0  
✔ readr   1.3.1       ✔ forcats 0.4.0  
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
Loading required package: magrittr

Attaching package: ‘magrittr’

The following object is masked from ‘package:purrr’:

    set_names

The following object is masked from ‘package:tidyr’:

    extract


Attaching package: ‘gridExtra’

The following object is masked from ‘package:dplyr’:

    combine


Attaching package: ‘cowplot’

The following object is masked from ‘package:ggpubr’:

    get_legend

The following object is masked from ‘package:ggplot2’:

    ggsave

Data

In [2]:
##### load the node data frame for the bipartite graph
nodes <- read.csv("BipartiteNetwork_nodes.csv")
head(nodes)
A data.frame: 6 × 35
SpeciesIDSuperfamilypiRNAWeighted.DegreeFamilylabel_only_genomesgenome_sizeEigenvector.Centralityg⋯yxClassDNMT1DNMT2DNMT3PIWIDNMTPhyloKuerzel
<fct><fct><fct><fct><int><fct><fct><fct><dbl><int>⋯<dbl><dbl><fct><fct><fct><fct><fct><fct><fct><fct>
Acanthocheilonema viteaeAcanthocheilonema_viteaegenome0 1338727genomecheat22034751.0 0.3059106128⋯-213.04019-323.57290genome-11-1-1-1Nematodes Clade IIIA.vit
Acyrthosiphon pisum Acyrthosiphon_pisum genome1100734868genomecheat541675271.00.5898820209⋯-486.28683-251.11584genome1 11 1 1 Arthropods A.pis
Amphimedon queenslandicaAmphimedon_queenslandicagenome0 43261462genomecheat166678968.00.3290055 66⋯ 61.55285-192.25584genome1 11 1 1 Other A.que
Ancylostoma caninum Ancylostoma_caninum genome1 81528305genomecheat465749605.00.6383859209⋯-854.83905 37.20678genome-11-11 -1Nematodes Clade V A.can
Ancylostoma ceylanicum Ancylostoma_ceylanicum genome1 66767534genomecheat313092201.00.6013092209⋯-936.88617 -24.83938genome-11-11 -1Nematodes Clade V A.cey
Anopheles darlingi Anopheles_darlingi genome1 2000107genomecheat136949910.00.3382292209⋯ -11.72634-108.50796genome-11-11 -1Arthropods A.dar

Figure 3a

In [3]:
##### created in gephi and saved as png
gephi1<-ggdraw() +
   draw_image("Bipart.png")
gephi1

Figure 3b

In [4]:
tol_muted<- c('#332288','#44AA99','#117733','#999933','#DDCC77','#CC6677','#882255','#88CCEE')

phylo_bipaplotlegend <- ggplot(nodes)+
                geom_point(data=subset(nodes,Type=='TE'),aes(x=x,y=y),color="#d9d9d9",size=0.01)+
                geom_point(data=subset(nodes,Type=='Genome'),aes(x=x,y=y,color=Phylo),size=2,shape=19)+
                theme_void()+ theme(legend.position='bottom',legend.direction="vertical")+
                    scale_colour_manual(values=tol_muted)+scale_fill_manual(values=tol_muted)+
#                 scale_color_manual(values=pal8_no_light_yellow)+scale_fill_manual(values=pal8_no_light_yellow)+
                coord_fixed(ratio = 1)+labs(color='',fill='')+
                guides(color=guide_legend(,override.aes = list(size = 5,shape=15),ncol=4))+
    theme(text=element_text(size=15,  family="Times New Roman"))
phylo_bipaplotlegend

Figure 3c

In [5]:
bipa_piwiplot<- ggplot(nodes)+
    geom_point(data=subset(nodes,Type=='TE'),aes(x=x,y=y),colour="#d9d9d9",size=0.01)+
    geom_point(data=subset(nodes,Type=='Genome'),aes(x=x,y=y,color=PIWI),size=2)+
    theme_void()+#+scale_color_brewer(type='qual')+
    scale_color_manual(values=c('#31688EFF','#FDE725FF',"#d9d9d9" ),labels=c('no PIWI','PIWI','TEs'))+   
    labs(color='')+coord_fixed(ratio = 1)+
    guides(color=guide_legend(,override.aes=list(shape=15,size=5)))+
    theme(text=element_text(size=15,  family="Times New Roman"),legend.position='bottom')

bipa_piwiplot

Figure 3d

In [6]:
bipa_dnmtplot<- ggplot(nodes)+
    geom_point(data=subset(nodes,Type=='TE'),aes(x=x,y=y),colour="#d9d9d9",size=0.01)+
    geom_point(data=subset(nodes,Type=='Genome'),aes(x=x,y=y,color=DNMT),size=2)+
    theme_void()+ theme(legend.position='bottom')+
    scale_color_manual(values=c("#440154FF",'#35B779FF' ),labels=c('no DNMT','DNMT'))+
    labs(color='')+coord_fixed(ratio = 1)+
    guides(color=guide_legend(,override.aes=list(shape=15,size=5)))+
    theme(text=element_text(size=15,  family="Times New Roman"),legend.text.align = 0)
bipa_dnmtplot

Figure 3

In [7]:
options(repr.plot.width=15, repr.plot.height=15)


myfigure <- as_ggplot(arrangeGrob(gephi1,phylo_bipaplotlegend,bipa_piwiplot,bipa_dnmtplot, ncol=2,nrow=2))+                                
               draw_plot_label(label = c("A", "B", "C",'D'), size = 20,
                    x = c(0,0.5,0,0.5), 
                    y = c(1,1,0.5,0.5))
myfigure
In [ ]: